/**
 * @author zfc
 */

/**  
*获取本页面URL中传递的参数<br/>
*@param name 参数名  <br/>
*@return name参数名所对应的值,当name不存在时,返回null
*/
function getUrlArg (name){
	var queryString = window.location.search;
	var arg = null;
	//去掉问号
	var reg = /\?/g;
	queryString = queryString.replace(reg,"");
	if(queryString.length>0){
	    // 分离参数对 key=value&key2=value2  
	    var parameters = queryString.split("&");  
	    var pos, paraName, paraValue;  
	    for(var i=0; i<parameters.length; i++)  
	    {  
	        // 获取等号位置  
	        pos = parameters[i].indexOf('=');  
	        if(pos == -1) { continue; }  
	   
	        // 获取name 和 value  
	        paraName = parameters[i].substring(0, pos);  
	        paraValue = parameters[i].substring(pos + 1);  
	   
	        // 如果查询的name等于当前name，就返回当前值
	        if(paraName == name) arg = decodeURIComponent(paraValue);
	    }  
	}
	return arg;
}

//JQUERY EXTENDING FOR SEARCH BOX TIPS
(function($){
	$.fn.textRemindAuto = function(options){
		options = options || {};
		var defaults = {
			blurColor: "#999",
			focusColor: "#333",
			auto: true,
			chgClass: ""
		};
		var settings = $.extend(defaults,options);
		$(this).each(function(){
			if(defaults.auto){
				$(this).css("color",settings.blurColor);
			}
			var v = $.trim($(this).val());
			if(v){
				$(this).focus(function(){
					if($.trim($(this).val()) === v){
						$(this).val("");
					}
					$(this).css("color",settings.focusColor);
					if(settings.chgClass){
						$(this).toggleClass(settings.chgClass);
					}
				}).blur(function(){
					if($.trim($(this).val()) === ""){
						$(this).val(v);
					}
					$(this).css("color",settings.blurColor);
					if(settings.chgClass){
						$(this).toggleClass(settings.chgClass);
					}
				});	
			}
		});
	};
})(jQuery);